-
-
Notifications
You must be signed in to change notification settings - Fork 515
Improve types of BaseDatabaseOperations
#2238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
style argument of BaseDatabaseOperations.sql_flushstyle argument of BaseDatabaseOperations.sql_flush
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style argument of BaseDatabaseOperations.sql_flushBaseDatabaseOperations
|
Made some other improvements to remove some unneeded subclass overrides. There's more work needed here, but I don't want to process everything at once |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Few suggestions.
| def sequence_reset_sql(self, style: Style, model_list: Sequence[type[Model]]) -> list[Any]: ... | ||
| def execute_sql_flush(self, sql_list: list[str]) -> None: ... | ||
| def sequence_reset_by_name_sql(self, style: Style, sequences: list[dict[str, str | None]]) -> list[str]: ... | ||
| def sequence_reset_sql(self, style: Style, model_list: list[type[Model]]) -> list[str]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since sequence_reset_sql only iterates over the model_list, I typing this as list seems too strict. Sequence[] or Iterable[] would be better.
Same for execute_sql_flush
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for list as these methods receive an actual list at runtime (e.g. sequence_reset_sql receives the result of sql_flush), so I assumed it is safe to allow BaseDatabaseOperations subclasses to rely on the available attributes/methods of list in these methods. On the other hand, keeping Sequence seems fine as well
| def prep_for_like_query(self, x: object) -> str: ... | ||
| def prep_for_iexact_query(self, x: object) -> str: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think Any has been preferred over object recently.

I have made things!
Related issues